package canss.webservice.service;

import org.apache.beehive.controls.api.bean.Control;
import org.apache.beehive.controls.api.bean.ControlImplementation;

import canss.webservice.service.PortalIntraWebServiceControlBean;

import canss.supports.basic;



import java.io.Serializable;

@ControlImplementation
public class LoginControlImpl implements LoginControl, Serializable
{
	private static final long serialVersionUID = -7123338478943195272L;
	@Control
	PortalIntraWebServiceControl control; //control = (control==null)?new PortalIntraWebServiceControlBean():control;
	
	public boolean logincheckForCP(String _pid, String _session)
	{
		if(basic.isEmpty(_pid) || basic.isEmpty(_session))
			return false;
		control = (control==null)?new PortalIntraWebServiceControlBean():control;
		Integer ret = control.checkExstenceOfSession(_pid, _session);
		if(ret!=null)
			return  ret.intValue() == basic.DEFAULT_PERSONTYPE_CP;
		return false;
	}
	public boolean logincheckForOP(String _pid, String _session)
	{
		if(basic.isEmpty(_pid) || basic.isEmpty(_session))
			return false;
		control = (control==null)?new PortalIntraWebServiceControlBean():control;
		Integer ret = control.checkExstenceOfSession(_pid, _session);
		if(ret!=null)
			return  ret.intValue() == basic.DEFAULT_PERSONTYPE_OPERATOR;
		return false;
	}
	public boolean logincheckForUser(String _pid, String _session)
	{
		if(basic.isEmpty(_pid) || basic.isEmpty(_session))
			return false;
		control = (control==null)?new PortalIntraWebServiceControlBean():control;
		Integer ret = control.checkExstenceOfSession(_pid, _session);
		if(ret!=null)
			return  ret.intValue() == basic.DEFAULT_PERSONTYPE_USER;
		return false;
	}
	public boolean logincheckForThird(String _pid, String _session)
	{
		if(basic.isEmpty(_pid) || basic.isEmpty(_session))
			return false;
		control = (control==null)?new PortalIntraWebServiceControlBean():control;
		Integer ret = control.checkExstenceOfSession(_pid, _session);
		if(ret!=null)
			return  ret.intValue() == basic.DEFAULT_PERSONTYPE_THIRDPARTY;
		return false;
	}

}